package test2.hash;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import org.apache.commons.lang.time.StopWatch;

public class HashMod {
	
	
	public static void main(String[] args) throws InterruptedException {
		StopWatch sw = new StopWatch();
		sw.start();
		Map<Integer, Integer> map = new HashMap<>();
		for(int i=0;i<100000;i++) {
			int x = Math.abs(HashAlgorithms.oneByOneHash(UUID.randomUUID().toString()));
			int y = x%128;
			if(!map.containsKey(y)) map.put(y, 1);
			else map.put(y, map.get(y)+1);
		}
		long t = sw.getTime();
		System.out.println("onebyonehash:" + t);
		System.out.println(map);
		
		map = new HashMap<>();
		for(int i=0;i<100000;i++) {
			int x = Math.abs(HashAlgorithms.bernstein(UUID.randomUUID().toString()));
			int y = x%128;
			if(!map.containsKey(y)) map.put(y, 1);
			else map.put(y, map.get(y)+1);
		}
		System.out.println("bernstein:" + (sw.getTime() - t));
		System.out.println(map);
		t = sw.getTime();
		
		map = new HashMap<>();
		for(int i=0;i<100000;i++) {
			int x = Math.abs(HashAlgorithms.FNVHash1(UUID.randomUUID().toString()));
			int y = x%128;
			if(!map.containsKey(y)) map.put(y, 1);
			else map.put(y, map.get(y)+1);
		}
		System.out.println("FNVHash1:" + (sw.getTime() - t));
		System.out.println(map);
		t = sw.getTime();
		
		map = new HashMap<>();
		for(int i=0;i<100000;i++) {
			int x = Math.abs(HashAlgorithms.RSHash(UUID.randomUUID().toString()));
			int y = x%128;
			if(!map.containsKey(y)) map.put(y, 1);
			else map.put(y, map.get(y)+1);
		}
		System.out.println("FSHash:" + (sw.getTime() - t));
		System.out.println(map);
		t = sw.getTime();
		
		map = new HashMap<>();
		for(int i=0;i<100000;i++) {
			int x = Math.abs(HashAlgorithms.JSHash(UUID.randomUUID().toString()));
			int y = x%128;
			if(!map.containsKey(y)) map.put(y, 1);
			else map.put(y, map.get(y)+1);
		}
		System.out.println("JSHash:" + (sw.getTime() - t));
		System.out.println(map);
		t = sw.getTime();
		
		map = new HashMap<>();
		for(int i=0;i<100000;i++) {
			int x = Math.abs(HashAlgorithms.PJWHash(UUID.randomUUID().toString()));
			int y = x%128;
			if(!map.containsKey(y)) map.put(y, 1);
			else map.put(y, map.get(y)+1);
		}
		System.out.println("PJWHash:" + (sw.getTime() - t));
		System.out.println(map);
		t = sw.getTime();
		
		map = new HashMap<>();
		for(int i=0;i<100000;i++) {
			int x = Math.abs(HashAlgorithms.ELFHash(UUID.randomUUID().toString()));
			int y = x%128;
			if(!map.containsKey(y)) map.put(y, 1);
			else map.put(y, map.get(y)+1);
		}
		System.out.println("ELFHash:" + (sw.getTime() - t));
		System.out.println(map);
		t = sw.getTime();
		
		map = new HashMap<>();
		for(int i=0;i<100000;i++) {
			int x = Math.abs(HashAlgorithms.BKDRHash(UUID.randomUUID().toString()));
			int y = x%128;
			if(!map.containsKey(y)) map.put(y, 1);
			else map.put(y, map.get(y)+1);
		}
		System.out.println("BKDRHash:" + (sw.getTime() - t));
		System.out.println(map);
		t = sw.getTime();
		
		map = new HashMap<>();
		for(int i=0;i<100000;i++) {
			int x = Math.abs(HashAlgorithms.SDBMHash(UUID.randomUUID().toString()));
			int y = x%128;
			if(!map.containsKey(y)) map.put(y, 1);
			else map.put(y, map.get(y)+1);
		}
		System.out.println("SDBMHash:" + (sw.getTime() - t));
		System.out.println(map);
		t = sw.getTime();
		
		map = new HashMap<>();
		for(int i=0;i<100000;i++) {
			int x = Math.abs(HashAlgorithms.DJBHash(UUID.randomUUID().toString()));
			int y = x%128;
			if(!map.containsKey(y)) map.put(y, 1);
			else map.put(y, map.get(y)+1);
		}
		System.out.println("DJBHash:" + (sw.getTime() - t));
		System.out.println(map);
		t = sw.getTime();
		
		map = new HashMap<>();
		for(int i=0;i<100000;i++) {
			int x = Math.abs(HashAlgorithms.DEKHash(UUID.randomUUID().toString()));
			int y = x%128;
			if(!map.containsKey(y)) map.put(y, 1);
			else map.put(y, map.get(y)+1);
		}
		System.out.println("DEKHash:" + (sw.getTime() - t));
		System.out.println(map);
		t = sw.getTime();
		
		map = new HashMap<>();
		for(int i=0;i<100000;i++) {
			int x = Math.abs(HashAlgorithms.APHash(UUID.randomUUID().toString()));
			int y = x%128;
			if(!map.containsKey(y)) map.put(y, 1);
			else map.put(y, map.get(y)+1);
		}
		System.out.println("APHash:" + (sw.getTime() - t));
		System.out.println(map);
		t = sw.getTime();
		
		map = new HashMap<>();
		for(int i=0;i<100000;i++) {
			int x = Math.abs(HashAlgorithms.java(UUID.randomUUID().toString()));
			int y = x%128;
			if(!map.containsKey(y)) map.put(y, 1);
			else map.put(y, map.get(y)+1);
		}
		System.out.println("java:" + (sw.getTime() - t));
		System.out.println(map);
		t = sw.getTime();
		
		map = new HashMap<>();
		for(int i=0;i<100000;i++) {
			long x = Math.abs(HashAlgorithms.mixHash(UUID.randomUUID().toString()));
			int y = (int)x%128;
			if(!map.containsKey(y)) map.put(y, 1);
			else map.put(y, map.get(y)+1);
		}
		System.out.println("mixHash:" + (sw.getTime() - t));
		System.out.println(map);
		sw.stop();
//		System.out.println(JSON.toJSONString(map, true));
	}

}
